GraphQL queryのfragment
queryに対するエイリアスみたいな?
code:before
query {
Lift(id: "jazz-cat") {
name
status
capacity
night
elevationGain
trailAccess {
name
difficulty
}
}
Trail(id: "river-run") {
name
difficulty
accessedByLifts {
name
status
capacity
night
elevationGain
}
}
}
fragment <名前> on 型という形式で書く
code:after
fragment liftInfo on Lift {
name
status
capacity
night
elevationGain
}
query {
Lift(id: "jazz-cat") {
...liftInfo
trailAccess {
name
difficulty
}
}
Trail(id: "river-run") {
name
difficulty
accessedByLifts {
...liftInfo
}
}
}
被っててもおk
code:graphql
query {
allTrails {
...trailStatus
...trailDetails
}
}
fragment trailStatus on Trail {
name
status
}
fragment trailDetails on Trail {
name
night
}